from sqlalchemy import String, ForeignKey,Date
import datetime
from settings.publicvar import Base
from sqlalchemy.orm import Mapped,mapped_column
from typing_extensions import Annotated
from sqlalchemy.sql import func

auto_add_now = Annotated[datetime.datetime,mapped_column(nullable=False,server_default=func.now())]

class PublicFunds(Base):
    __tablename__='publicfunds'

    id:Mapped[int] = mapped_column(primary_key=True)
    billnum:Mapped[str] = mapped_column(String(25),unique=True,nullable=False)
    brief:Mapped[str] = mapped_column(String(120),nullable=False)
    school_id:Mapped[int] = mapped_column(ForeignKey('schoolinfo.id'))
    billperson:Mapped[str] = mapped_column(String(15),nullable=False)
    filldate:Mapped[datetime.date]=mapped_column(nullable=False)
    payeename:Mapped[str]=mapped_column(String(150),nullable=False)
    amount:Mapped[float]=mapped_column(nullable=False)
    createtime:Mapped[auto_add_now]
    mark:Mapped[str]= mapped_column(String(250),nullable=True)

